//
#include <Servo.h> 
 
Servo Left; 
Servo Right; 

unsigned long time;
unsigned long buffer = 500;
 
void setup() 
{ 
  Serial.begin(9600);
  Left.attach(6);  // attaches the servo on pin 6 to the servo object 
  Right.attach(7);
} 
 
void loop() 
{ 
  if (Serial.available()) {
    unsigned char wByte = Serial.read(); 
    switch(wByte){
    case 0x77: //w
      Left.write(135);
      Right.write(135);
      time = millis() + buffer;
    break;
    case 0x61: //a
      Left.write(45);
      Right.write(135);
      time = millis() + buffer;
    break;
    case 0x73: //s
      Left.write(45);
      Right.write(45);
      time = millis() + buffer;
    break;
    case 0x64: //d 
      Left.write(135);
      Right.write(45);
      time = millis() + buffer;
    break;
    case 0x57: //W
      Left.write(90);
      Right.write(90);
      time = millis() + buffer;
    break;
    case 0x41: //A
      Left.write(90);
      Right.write(90);
      time = millis() + buffer;
    break;
    case 0x53: //S 
      Left.write(90);
      Right.write(90);
      time = millis() + buffer;
    break;
    case 0x44: // D
      Left.write(90);
      Right.write(90);
      time = millis() + buffer;
    break;
    case 0x72: //r
      Left.write(90);
      Right.write(90);
    break;
    default:
      Left.write(90);
      Right.write(90);     
    break;
    }
  }
else if(millis() > time){  
  Left.write(90);
  Right.write(90);
}
} 
